package com.guigu.liuzhireng.controller;

import com.guigu.aop.OpLog;
import com.guigu.liuzhireng.pojo.Menu;
import com.guigu.liuzhireng.pojo.PageVo;
import com.guigu.liuzhireng.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("Menu.do")
public class MenuController {

    @Autowired
    MenuService menuService;

    @RequestMapping("Page")
    @ResponseBody
    public PageVo<Menu> Page(@RequestBody PageVo<Menu> pageVo){
        return menuService.Page(pageVo.getObj(),pageVo.getNum(),pageVo.getSize());
    }

    @RequestMapping("MenuAll")
    @ResponseBody
    public List<Menu> MenuAll(){
        return menuService.MenuAll();
    }

    @RequestMapping("Add")
    @OpLog(opModule = "菜单模块",operType = "添加菜单",operDesc = "此方法用于添加菜单")
    public String Add(Menu menu){
        int i = menuService.insert(menu);
        return "/menu/Menu.html";
    }

    @RequestMapping("UpDate")
    @OpLog(opModule = "菜单模块",operType = "修改菜单",operDesc = "此方法用于修改菜单")
    public String UpDate(Menu menu){
        int i = menuService.update(menu);
        return "/menu/Menu.html";
    }

    @RequestMapping("Delete")
    @OpLog(opModule = "菜单模块",operType = "删除菜单",operDesc = "此方法用于删除菜单")
    public String Delete(Integer id){
        int i = menuService.delete(id);
        return "/menu/Menu.html";
    }
}
